/**
@author		Jong Min, Lee
@date		  01/22/2014
@brief		Visible toolbar

copyright(c) Tae Young Soft. All right reserved. 2014
*/
#pragma once

#include "Taurus_Common/Monitor.h"
#include "TAURUS_CTRL/EXButton.h"
#include "Taurus_Util/Event.h"
#include "Taurus_Viewer/TBLayoutInfo.h"
#include "Taurus_Viewer/ToolboxStack.h"

/**
@brief  visible toolbar
*/
class CVisibleToolbar : public CWnd
{
  DECLARE_DYNAMIC(CVisibleToolbar)

public:
  typedef struct tagCreateParams
  {
    MonitorResolutionType theResType;

    unsigned int theMonitorIndex;

    tagCreateParams()
      : theResType(MonitorResolution_Normal)
      , theMonitorIndex(0)
    {}
  }CreateParams;

public:
  /**
  @brief		default constructor
  */
  CVisibleToolbar();

  /**
  @brief		destructor
  */
  virtual ~CVisibleToolbar();

  /**
  @brief		change position
  @param		enumPos toolbar position
  @param    rcWork workspace area
  @param    bRedraw flag indicating whether this is to be redrawn
  @return		ERROR_SUCCESS if succeeds, an error code if not
  */
  DWORD changePosition(ToolbarPosition enumPos,
                       const CRect& rcWork,
                       BOOL bRedraw);

  /**
  @brief		open toolbox data
  @param		arrToolboxes pointer to array of toolbox data to be open
  @param    nNumToolboxes the number of toolboxes to be open
  @param    bRedraw flag indicating whether toolbox stack be redrawn
  @return		ERROR_SUCCESS upon success, an error code otherwise
  */
  DWORD openToolboxes(const CToolboxData** arrToolboxes,
                      const unsigned       nNumToolboxes,
                      BOOL                 bRedraw);

  /**
  @brief		access to monitor index
  @return		monitor index
  */
  inline unsigned int getMonitorIndex() const
  {
    return m_theMonitorIndex;
  }

  /**
  @brief		event occurs when current selection of monitor layout combo box is changed
  */
  TEvent<CVisibleToolbar> onChangedCurSelMLayout;

  /**
  @brief		event occurs when current selection of study view layout combo box is changed
  */
  TEvent<CVisibleToolbar> onChangedCurSelSLayout;

  /**
  @brief		even occurs when hide button is clicked
  */
  TEvent<CVisibleToolbar> onClickedHide;

  /**
  @brief		update current selected monitor layout
  */
  void updateCurSelML();

  /**
  @brief		update current selected study view layout
  */
  void updateCurSelSL();

private:
  /**
  @brief	initialize controls	
  */
  void initControls();

  /**
  @brief		destroy all data members
  */
  void destroy();

  /**
  @brief		rearrange controls
  */
  void rearrangleControls();

  /**
  @brief		check whether createparams is legal
  @param		cParams createparams
  @return		TRUE if legal, FALSE if not
  */
  BOOL validateCreateParams(const CreateParams& cParams);

private:
  //monitor layout combo box control
  CComboBox m_cmbMonitorLayout;

  //show worklist button control
  CButton m_btnShowWorklist;

  //open previous study button control
  CButton m_btnPrevStudy;

  //open next study button control
  CButton m_btnNextStudy;

  //study view layout combo box control
  CComboBox m_cmbStudyViewLayout;

  //hide toolbar button control
  CButton m_btnHideToolbar;

  //show toolbox stack button control
  CButton m_btnShowToolboxStack;

  //show thumbnail button control
  CButton m_btnShowThumbnail;

  //toolbox stack control
  CToolboxStack m_wndToolboxStack;

  //minimize button control
  CButton m_btnMinimize;

  //exit button control
  CButton m_btnExit;

  //monitor resolution
  MonitorResolutionType m_enumResType;

  //monitor index
  unsigned int m_theMonitorIndex;

  //current toolbar position
  ToolbarPosition m_enumToolbarPos;

protected:
  DECLARE_MESSAGE_MAP()

  afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  afx_msg void OnPaint();
  afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  afx_msg void OnSize(UINT nType, int cx, int cy);
  afx_msg void OnDestroy();

  afx_msg void onSelchangComboMLayout();
  afx_msg void onSelchangedComboSLayout();
  afx_msg void onClickedHideBtn();
};
